import java.util.Stack;

public class MyStack2{
	private Stack<Integer> dataStack;
	private Stack<Integer> minStack;

	public MyStack2(){
		this.dataStack = new Stack<Integer>();
		this.minStack = new Stack<Integer>();
	}

	public void push(int newValue){
		if( this.minStack.isEmpty() || newValue<this.getMin() ){
			this.minStack.push(newValue);
		}else {
			int newMin = this.minStack.peek();
			this.minStack.push(newMin);
		}
		this.dataStack.push(newValue);
	}

	public int pop(){
		if( this.dataStack.isEmpty() ) {
			throw new RuntimeException(" Your stack is empty ?");
		}
		this.minStack.pop();
		return this.dataStack.pop();
	}

	public int getMin(){
		if( this.minStack.isEmpty() ){
			throw new RuntimeException("Your stack is empty !");
		}
		return this.minStack.peek();
	}
}
